package client;

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;



public class ClientGui extends JFrame{
	
	private JPanel  container;
	
	private JPanel  panel1;
	private JPanel  panel2;
	private JPanel  panel3;
	
	
	private JButton b1;
	private JButton b2;
	private JButton b3;
	
	private JLabel label1;
	private JLabel label2;
    
	private JTextField jtf1;
	private JTextField jtf2;
	private JTextField jtf3;
    
    private JTextArea textArea;
  
    private JScrollPane scrollPane;
  
	
	
	
	 public ClientGui(){

	     this.setTitle("CLIENT");
		 this.setSize(600, 600);	    	   
				 
		 container = new JPanel();
		 container.setLayout(null);			  
				 
		 panel1 = new JPanel();
		 panel1.setLayout(new GridLayout(0,3));
		 
		 panel2 = new JPanel();
		 panel2.setLayout(new GridLayout(0,2));
		 
		 panel3 = new JPanel();
		 panel3.setLayout(null);	
		 
		 
		 b1 = new JButton ("send");
		 b2 = new JButton ("connect");
		 b3 = new JButton ("send message");
		
		 jtf1= new JTextField("");
		 jtf2= new JTextField("");	
		 jtf3= new JTextField("");	
	    
		 textArea = new JTextArea();	     
	     scrollPane = new JScrollPane(textArea);	    
	     
	     label1 = new JLabel();
	     label2 = new JLabel();
	     
	    
	     label1.setText("User Name:");
	     b1.addActionListener(new Action());
	     
         panel1.setBounds(10,10,400,20);
         panel1.add(label1);
         panel1.add(jtf1);
         panel1.add(b1);
         
         
	     label2.setText("Connect to cluster:");
	     b2.addActionListener(new Action());
	     
         panel2.setBounds(10,10,400,20);
         panel2.add(label2);     
         panel2.add(b2);
         panel2.setVisible(false);
         
		 
		 textArea.setEditable(false);
		 scrollPane.setBounds(0,0,400,300);
		 
		 
		 jtf3.setBounds(0,300,250,20);
		 jtf3.addKeyListener(new KeyAction());
		  		
		  
		 b3.addActionListener(new Action());
		 b3.setBounds(250,300,150, 20);
		 
		 
		 panel3.setBounds(10,60,500, 500);
		 panel3.add(scrollPane);
		 panel3.add(jtf3);
		 panel3.add(b3);
		 
		 panel3.setVisible(false);

		  //container.add(label1);		  		  
		  container.add(panel1);
		  container.add(panel2);
		  container.add(panel3);
		  
		 

		  this.setContentPane(container); 
	      this.setVisible(true);
	  }


   
		public  void ActualiserTextArea(String newLine) {
			
			newLine=newLine+" \n";
			textArea.append(newLine);
			
		
		}

	
		
	
		
		
	public JButton getB1() {
			return b1;
		}


		public void setB1(JButton b1) {
			this.b1 = b1;
		}



	public JButton getB2() {
		return b2;
	}

	public void setB2(JButton b2) {
		this.b2 = b2;
	}

	public JButton getB3() {
		return b3;
	}

	public void setB3(JButton b2) {
		this.b3 = b3;
	}
	

	public JPanel getPanel1() {
		return panel1;
	}



	public void setPanel1(JPanel panel1) {
		this.panel1 = panel1;
	}


	public JPanel getPanel2() {
		return panel2;
	}



	public void setPanel2(JPanel panel2) {
		this.panel2 = panel2;
	}


	public JPanel getPanel3() {
		return panel3;
	}



	public void setPanel3(JPanel panel3) {
		this.panel3 = panel3;
	}



	public JTextField getJtf1() {
		return jtf1;
	}


	public void setJtf1(JTextField jtf) {
		this.jtf1 = jtf1;
	}
	
	public JTextField getJtf2() {
		return jtf2;
	}


	public void setJtf2(JTextField jtf) {
		this.jtf2 = jtf2;
	}
	
	public JTextField getJtf3() {
		return jtf3;
	}


	public void setJtf3(JTextField jtf) {
		this.jtf3 = jtf3;
	}
	
	

}
